<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增动账信息')"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-user-add" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-3 control-label">产品信息：</label>
            <div class="col-sm-8">
                <select class="form-control m-b" name="assetName" required>
                    <option value="">-请选择-</option>

                    <option th:each="assetName:${holdAssetNameList}" th:value="${assetName}"
                            th:text="${assetName}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">份额/股数：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="numberOf" id="numberOf" required >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">交易金额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="amount" id="amount" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea class="form-control" type="number" name="remark" id="remark"></textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: jasny-bootstrap-js"/>
<script type="text/javascript">

    var prefix = ctx + "finance/zcjy";

    $("#form-user-add").validate({
        onkeyup: false,
        rules: {
            numberOf: {
                required: true
            },
            amount: {
                required: true
            },
            assetName: {
                minlength:1,
                required: true
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            debugger;
            var data =  $('#form-user-add').serialize();
            var config = {
                url: prefix + "/saleAssetOpt",
                type: "post",
                dataType: "json",
                data: data,
                async:false,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍候...");
                    $.modal.disable();
                },
                success: function(result) {
                    if (typeof callback == "function") {
                        debugger;
                        callback(result);
                    }
                    $.operate.successCallback(result);
                }
            };
            $.ajax(config)
            $.modal.close();
            window.refreshTab();
        }
    }

</script>
</body>
</html>
